{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.datasets import make_classification\n",
    "from sklearn.model_selection import train_test_split\n",
    "from sklearn.ensemble.gradient_boosting import GradientBoostingClassifier\n",
    "from sklearn.preprocessing import OneHotEncoder\n",
    "from sklearn.linear_model import LogisticRegression\n",
    "from sklearn.metrics import roc_curve,auc\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "# 弱分类器的数目\n",
    "n_estimator = 10\n",
    "# 随机生成分类数据。\n",
    "X, y = make_classification(n_samples=80000)  \n",
    "# 切分为测试集和训练集，比例0.5\n",
    "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.5)\n",
    "# 将训练集切分为两部分，一部分用于训练GBDT模型，另一部分输入到训练好的GBDT模型生成GBDT特征，然后作为LR的特征。这样分成两部分是为了防止过拟合。\n",
    "X_train, X_train_lr, y_train, y_train_lr = train_test_split(X_train, y_train, test_size=0.5)\n",
    "# 调用GBDT分类模型。\n",
    "grd = GradientBoostingClassifier(n_estimators=n_estimator)\n",
    "# 调用one-hot编码。\n",
    "grd_enc = OneHotEncoder()\n",
    "# 调用LR分类模型。\n",
    "grd_lm = LogisticRegression()\n",
    "\n",
    "\n",
    "'''使用X_train训练GBDT模型，后面用此模型构造特征'''\n",
    "grd.fit(X_train, y_train)\n",
    "\n",
    "# fit one-hot编码器\n",
    "grd_enc.fit(grd.apply(X_train)[:, :, 0])\n",
    "\n",
    "''' \n",
    "使用训练好的GBDT模型构建特征，然后将特征经过one-hot编码作为新的特征输入到LR模型训练。\n",
    "'''\n",
    "grd_lm.fit(grd_enc.transform(grd.apply(X_train_lr)[:, :, 0]), y_train_lr)\n",
    "# 用训练好的LR模型多X_test做预测\n",
    "y_pred_grd_lm = grd_lm.predict_proba(grd_enc.transform(grd.apply(X_test)[:, :, 0]))[:, 1]\n",
    "# 根据预测结果输出\n",
    "fpr_grd_lm, tpr_grd_lm, thresholds  = roc_curve(y_test, y_pred_grd_lm)\n",
    "auc = auc(fpr_grd_lm, tpr_grd_lm)  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 0.00452427,  0.9385351 ,  0.97040414, ...,  0.02015139,\n",
       "        0.99264983,  0.99264983])"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y_pred_grd_lm"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [],
   "source": [
    "import seaborn as sb\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.collections.PathCollection at 0x7f27e2077898>"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAEDCAYAAAA7jc+ZAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAG/hJREFUeJzt3X2QXNV55/FvawRCQi0kUIMYYYRe4AFip2qlVFaIlw3GsUPFDiFxEsD24he5skT2lgIOsmEDttcGpBQCU9lUqvDi1LoWkZS3As4GsWCi7GLA3ggWR+xaDxIayWhGSDNohEYS6GXU+8c5V7q66nnhdk9m5vD7VKn69rnnnvucc7ufvvM0M1Tq9ToiIpKuCaMdgIiIjCwlehGRxCnRi4gkToleRCRxSvQiIolTohcRSdzEZg42sw8CjwOr3f0vCvuuBu4BjgDu7kubOZeIiJRT+o7ezKYADwE/GqDLXwK/4+5XAtPM7DfKnktERMprpnTzLnAtsGOA/YvcPdvXDZzVxLlERKSk0one3Y+6+8FB9u8DMLNzgV8Hnix7LhERKW9Ev4w1s7OBHwK3uHvvSJ5LREQaa+rL2MGYWZVwF/81d392qP71er1eqVRGKhwRkVQNmThblegbnWg14b/GeWZYA1Qqd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dTyuZ2WOEBHgUOI/wW/x/ONBd73hjZp8FznH3lfH5q8CvuXtPse9YKt08Ragx/XX8n5S8McrxtJS7X5Ftm9n3gO8llOTnEb5AvyqVJB89DXwdeNjMFgKdiSX5aYT/OOCa1JI8gLvfkG3HD+2OVJJ89DTwvfhfTp0JnN4oycMYSvTu/lMzu9bMXiCUA5aNdkwjaGz8GNU6XyC80J40s6yc81F3PzK6YTXH3V80s5fM7HnCdxCpvSb/gPA/BPqb3HX7t+6+fXTDkuFw9y4z+wHh//VRB740UN8xU7oREZGRMWb+O3oRERkZSvQiIolTohcRSZwSvYhI4pToRUQSp0QvIpI4JXoRkcQp0YuIJO7/A3TAZZv7yFMoAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f27e20d5518>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(X[:,0],y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYEAAAEbCAYAAAA8pDgBAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xl4FFXWwOFfkmYJGkggDci+yQFEkEUREHEfHRG3cUQc5RNXxg2X0Rl03JVRBAVGBcF9wV1wR3REQUEFUXDhKCg7YkACAUxCkv7+qOrQSXeSBlLphDrv8/DQXXWr6tzuzj1Vt6puJYVCIYwxxvhTcqIDMMYYkziWBIwxxscsCRhjjI9ZEjDGGB+zJGCMMT5mScAYY3wskOgATEkiUgQsAwqAJCAF+Bi4SlX/qORtnQYMUtWLKnO9iSYihwE7VPVbEbkcaKyqt3q8zSKghaqu83I7MbbbEWiiqnN2c7l7gBWq+mg5ZU4AvlfVNfGUr85E5AngJ1W9J9GxVDeWBKqfEDBQVdcDiEgt4EVgFPDvytyQqk4HplfmOquJC4C5wLeq+lAVbTNRN9ycjvN3v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rVdnIRQeuz+kLvNv4pIR5yRHGeLyJkVVU5VN4jIzyJyKHA2MNKdlYtztFHRsx6KzwmIyAxgpTt8NMAzwMWq+rHbhRVr5NR4Pw/jE9YdZKqbsh6S0Rhnbx+cxrNO5EwR6SUi56vq16p6J7AQ5/zAXLc8IpIsImPdrpx4/QgEI57ZexwwX0TaiMhIVf1RVccBrwPdSy1bhPPg99KeAy4EMlT1a3faXGCIG2emezVRRS4HbheRZu77xsD37vmRs9j1GUXGsbefh9nHWBIw1U1Zw9qOA54RkXdxHiDyu4iMiSi/DPiLiMwVkQ9xToh+inMSNEdEPsPpO9+sqtnxBqOquTgN9ktud9ExwM04J4J7iMh8EfkAaINzMjjSLGCyiJxWql6vA+cAz0dMuxo4XUQ+wenOqvCksPsc4f8Aj7qT7sO5AmgG8ATQUkSuwvm8LhCR24H/Atv29PMw+x4bStoYY3zMjgSMMcbHLAkYY4yPWRIwxhgfsyRgjDE+ZknAGGN8zJKAMcb4mCUBY4zxMUsCxhjjY/8Pg0XX7YywU6gAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f27e200b518>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    " #画平均ROC曲线  \n",
    "#print mean_fpr,len(mean_fpr)  \n",
    "#print mean_tpr  \n",
    "plt.plot(fpr_grd_lm, tpr_grd_lm, 'k--',  \n",
    "         label='Mean ROC (area = %0.2f)' % auc, lw=2)  \n",
    "  \n",
    "plt.xlim([-0.05, 1.05])  \n",
    "plt.ylim([-0.05, 1.05])  \n",
    "plt.xlabel('False Positive Rate')  \n",
    "plt.ylabel('True Positive Rate')  \n",
    "plt.title('Receiver operating characteristic example')  \n",
    "plt.legend(loc=\"lower right\")  \n",
    "plt.show() "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
